package com.example.demo.controller;

import com.example.demo.domain.po.Terminal;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Objects;

/**
 * @author xieluoyin
 */
@RestController
public class TerminalController {
    @PostMapping(value = "/terminal", consumes = "application/json;charset=utf-8", produces = "application/json;charset=utf-8")
    public ResponseEntity<Object> add(@Valid @RequestBody Terminal terminal, BindingResult bindingResult) {

        if (bindingResult.hasErrors()) {

            System.out.println(Objects.requireNonNull(
                    bindingResult.getFieldError()).
                    getDefaultMessage());
        }
        return new ResponseEntity<>(null, HttpStatus.OK);
    }
    }
